#include "gtest/gtest.h"
#include "Callback.h"
// Note for callback 
//  can not encapsulate, just show some examples to impl the callback

TEST(CallbackTest, testTheFunctionImpl){
    test::callback::CallbackUse<int()> cbu = [](){
        return 10;
    };
    ASSERT_EQ(10, cbu.call());

    cbu.set([](){
        return 12;
    });
    ASSERT_EQ(12, cbu.call());
}

TEST(CallbackTest, testClassic){
    EXPECT.reset().operation("setDisconnectCallback").operation("disconnect").operation("cbDisconnect");

    test::callback::Client client;
    {
        TRACER.reset();
        client.setDisconnectCallback(&test::callback::cbDisconnect);
        client.disconnect();
        ASSERT_EQ(EXPECT, TRACER);
    }
    {
        TRACER.reset();
        client.setDisconnectCallback([](){
            TRACER.operation("cbDisconnect");
        });
        client.disconnect();
        ASSERT_EQ(EXPECT, TRACER);
    }
    {
        TRACER.reset();
        test::callback::OnDisconnect cbDisconnect;
        client.setDisconnectCallback(cbDisconnect);
        client.disconnect();
        ASSERT_EQ(EXPECT, TRACER);
    }
}

TEST(CallbackTest, testManyCallbackInOneObject){
    //TODO:
}

//TODO:   Add action(objectName, actionName) for Tracer 
//  Add action(object, action, args) for Tracer
//  Add operator << to  Tracer
//  Add TRACER.arg(std::string)
